<template>
  <div class="tree">
    <div class="type-header">类型列表</div>
    <div class="type-tree">
      <el-tree
        :data="dataList"
        node-key="type"
        ref="deptTree"
        default-expand-all
        :expand-on-click-node="false">

        <div draggable="true" class="custom-tree-node" slot-scope="{ node,data }">
          <div class="node-item">
            <div class="icon">
<!--              <img v-if="isSubMenu(data)" width="20" height="20" src="/static/img/user/dept.png" />-->
              <img width="20" height="20" src="/static/img/user/dept.png" />
            </div>
            <div class="label">{{data.description}}</div>
            <div class="actions" @click.stop>
            </div>
          </div>
        </div>
      </el-tree>
    </div>
  </div>
</template>

<script>
export default {
  name: 'type-tree',
  data() {
    return {
      dataList: [],
      pageIndex: 1,
      pageSize: 10
    }
  },
  mounted() {
    this.getDataList()
  },
  methods: {
    getDataList() {
      this.$http({
        url: this.$http.adornUrl('/sys/dict/certList'),
        method: 'post',
        data: {
          page: this.pageIndex,
          limit: this.pageSize
        }
      }).then(res => {
        console.log(res)
        if (res && res.code === 200) {
          this.dataList = res.data
        } else {
          this.dataList = []
        }
        this.dataListLoading = false
      })
    },
    isSubMenu(dept) {
      console.log(dept, ';;;;')
    }
  }
}
</script>

<style scoped>
.tree{
  height: 100%;
  width: 300px;
  border-right: 2px solid #eee;
}
.type-header {
  height: 40px;
  text-align: center;
  line-height: 40px;
  border-bottom: 1px solid #eee;
}
.type-tree {
  height: calc(100% - 40px);
  overflow-y: auto;
  padding: 5px 0;
}
.node-item{
  display: flex;
}
.label{
  margin: 3px 0 0 6px;
}
</style>
